package com.joysuch.wwyt.risk.service;


import com.joysuch.wwyt.bp.entity.bean.BpRecordItemBean;
import com.joysuch.wwyt.core.bean.SimpleSelectListBean;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.exception.ApiBusinessException;
import com.joysuch.wwyt.core.exception.BusinessRestrictionsException;
import com.joysuch.wwyt.risk.bean.*;
import com.joysuch.wwyt.risk.entity.*;
import com.joysuch.wwyt.risk.entity.vo.RiskItemEvalCountRecordVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;
import java.util.Map;

public interface RiskEvaluationBusinessService {
    RiskEvaluationBusiness saveBusiness(RiskEvaluationBusinessBean bean);

    RiskEvaluationBusinessShowBean getBusinessById(Long businessId);

    Page<RiskEvaluationBusinessPageBean> pageRiskDistrictEvaluation(Pageable page, RiskDistrictStableRiskListSearchBean condition);

    RiskPointEvaluationBusiness savePointEvaluation(RiskPointEvaluationBusinessBean bean);

    RiskPointEvaluationBusiness savePointEvaluationForAssessment(RiskPointEvaluationBusinessBean bean) throws BusinessRestrictionsException;

    RiskPointEvaluationBusinessShowBean getPointEvaluation(Long riskPointId, Integer pointAnalyzeType, Long analyzeWayId, Long riskPointEvaluationId);

    RiskPointEvaluationBusinessShowBean getPointEvaluationForAssessment(Long riskPointId, Long analyzeWayId, Long riskEvaluationId);

    public String getPointTypeName(Long pointId);

    Page<RiskPointOfDistrictListBean> getPointInDistrictList(Long riskDistrictId, Pageable page);

    Page<RiskControPointBean> pageControlList(Pageable pageable, RiskControlSearchBean condition);

    RiskPointItemPageBean pagePointEvaluationDetail(Pageable pageable, RiskControlSearchBean condition, Long pointId);

    RiskPointEvalBean getPointEvaluationDetail(Pageable pageable, Long pointId);

    RiskPointEvaluationDetail saveControl(RiskPointControlBean bean);

    void saveListControl(RiskPointControlBean bean);

    /**
     * "管控-排查措施分页
     *
     * @param pageable
     * @param condition
     * @return
     */
    ResultBean pageControlPointDetail(Pageable pageable, RiskControlSearchBean condition);

    public List<RiskControAnalyzeDetailBean> getDetailList(List<RiskControAnalyzeDetailBean> detailBeanList, List<RiskPointEvaluationDetail> detailList);

    public String getControlStateName(Integer controlState);

    public String getDepartName(Long departId);

    public String getUserName(Long userId);

    List<SimpleSelectListBean> getControlLevelList();

    /**
     * 作业风险点评估
     *
     * @param riskEvaluationId 作业票-风险点库评估id
     * @param riskDistrictId   风险区域id
     * @param flag             0失效;1生效
     * @param workSafetyCode   作业编码
     */
    public void changeDistrictLevelFromLibraryPoint(Long riskEvaluationId, Long riskDistrictId, Integer flag, String workSafetyCode);

    public boolean editDistrictLevel(RiskDistrict riskDistrict, Integer oldLevel, String message);

    int batchEditDistrictLevel(List<RiskDistrictBatchBean> riskDistricts);

    void editDistrictEvaluationAndLevel(Long oldRiskDistrictId, Long riskDistrictId);

    ResultBean getRiskPointEvaluationJson(Long riskPointId, Long riskPointEvaluationId, Long workSafetyDistrictId);

    List<SimpleSelectListBean> getControlStateList();

    RiskDistrictEvalBean editDistrictEvaluation(RiskEditDistrictEvaluationBean bean);

    int batchSavePointEvaluation(List<RiskPointEvaluationBusinessBean> riskPointEvaluationBusinessList, RiskEvaluationExcelMapBean mapBean);

    RiskPointEvaluationjsonBean getPointTitles(RiskEvaluationAnalyzeWay analyzeWay, RiskPointEvaluationjsonBean bean, Integer analyzeType);

    RiskPointEvaluationjsonItemBean getjsonItemBean(List<RiskPointEvaluationItem> itemList, Map<Long, RiskEvaluationTargetItem> targetItemMap, Map<Long, List<RiskPointEvaluationDetail>> itemDeatilMap, int j, ExcelExportToolMapBean toolBean, String typeFlag);

    /**
     * 大屏-管控措施分页
     *
     * @param pageable
     * @param condition
     * @return
     */
    ResultBean pageScreenPointDetails(Pageable pageable, RiskControlSearchBean condition);

    RiskControlDetailed getRiskControlDetailedList(Long pointId);

    ResultBean getRiskPointControl(RiskControlSearchBean searchBean, Long riskPointId);

    ResultBean getRiskPointControlForScreenPage(RiskControlSearchBean searchBean);

    ResultBean getPointHistoryEvaluationData(Long riskPointId, Pageable page);

    void deleteByPointEvaluationId(Long riskPointEvaluationId) throws ApiBusinessException;

    /**
     * @param riskDistrict
     * @param oldLevel
     * @param minPointLevel
     * @param message
     */
    void editRealDistrictLevel(RiskDistrict riskDistrict, Double oldLevel, Integer minPointLevel, String message);

    /**
     * @param flag       0 失效  1有效
     * @param itemRecord item记录
     */
    void recalculateRealRiskLevel(Integer flag, RiskItemEvalCountRecordVo itemRecord);

    /**
     * 产生未检
     *
     * @param uncheckedBeanList
     */
    void convertUnCheckedRealRiskLevel(List<BpRecordItemBean> uncheckedBeanList);

    /**
     * 根据排查计划消除未检
     *
     * @param itemPlanMap
     * @param url
     */
    void convertCheckedRealRiskLevel(Map<Long, List<Long>> itemPlanMap, String url);


    Integer getMinPointRealRiskLevel(RiskDistrict riskDistrict);

    /**
     * 区域动态等级计算
     *
     * @param records
     * @param message 消息来源
     */
    void editDynamicDistrictLevel(List<RiskDynamicRecord> records, String message);

    /**
     * 获取已评估风险分区数量
     *
     * @return
     */
    Long getDistEvalNum();
}
